<template>
	<sy-navigation :homejb="'invite'" :showTurnB='true' :scrollTopNum="scrollTopNum" @showTurnHandle="showTurnHandle" :titBgColor="'#00aaff'">
		<template #header>
			<view class="header_title_c">
				 邀请有礼
			</view>
		</template>
		<view class="invite_view">
			<view class="invite_box">
				<view class="tit_c">
					每邀请5为好友注册成功即可获得以下奖励
				</view>
				<view class="img_box">
					<image src="../../static/mine/yq2.png" class="yq2_img"></image>
					<view class="yq2_box">
						<view class="t1p">
							邀请好友可获得免费评估
						</view>
						<view class="t2p">
							您已邀请: <span class="c_span">{{userInfo.share_num%5}}/5</span>
						</view>
					</view>
				</view>
				<view class="list_box_b">
					<view class="list_tit">
						我的邀请
					</view>
					<view class="list_box" v-if="yaoqingList.length > 0">
						<view class="list_item" v-for="item in yaoqingList">
							<view class="left_b">
								<image :src="baseUrl+ item.avatar" class="yqt_img"></image>
								<view class="t_name">
									{{item.nickname}}
								</view>
							</view>
							<view class="right_time">
								{{item.createtime}}
							</view>
						</view>
					</view>
					<view class="pging_sy sm_top" v-if="yaoqingList.length == 0">
						<image src="../../static/mine/yqno.png" class="doing_img"></image>
						<view class="do_text">
							数据空！快去邀请吧！
						</view>
					</view>
				</view>
			</view>
			<view class="btn_yx_box">
				<button class="btn_yx" open-type="share" @click="funxiang">邀请好友</button>
			</view>
		</view>
		
	</sy-navigation>
</template>

<script>
	export default {
		data() {
			return {
				scrollTopNum:0,
				yaoqingList:[],
				page:1,
			};
		},
		onPageScroll(e) {
		    // e.scrollTop 表示当前页面滚动的距离
		    console.log('页面滚动距离：', e.scrollTop);
			this.scrollTopNum = e.scrollTop;
			
		},
		// 1.发送给朋友
		onShareAppMessage(res) {
			let path = ''
			if(uni.getStorageSync('shareId')){
				path = '/pages/home/home?shareId='+uni.getStorageSync('shareId')
			}else{
				path = '/pages/home/home'
			}
			return {
				title: '志愿填报',
				path,
				// imageUrl: this.share.imageUrl,
			}
		},
		//2.分享到朋友圈
		onShareTimeline(res) {
			let path = ''
			if(uni.getStorageSync('shareId')){
				path = '/pages/home/home?shareId='+uni.getStorageSync('shareId')
			}else{
				path = '/pages/home/home'
			}
			return {
				title: '志愿填报',
				path,
				// imageUrl: this.share.imageUrl,
			}
		},
		computed:{
			baseUrl(){
				return this.$store.state.baseUrl
			},
			userInfo(){
				return this.$store.state.userInfo
			},
		},
		onLoad() {
			this.getData();
		},
		onPullDownRefresh(){
			this.dataList = [];
			this.page = 1;
			this.isCanUp = true;
			this.getData();
			setTimeout(()=>{
				uni.stopPullDownRefresh() 
			},1000)
		},
		onReachBottom(){
		    let that = this
		    //每次上拉加载的数据比上一次多十个
			if(this.isCanUp){
				++this.page;
				setTimeout(()=>{
					that.getData()
				},200)
			}
		},
		methods:{
			getData(){
				uni.showLoading()
				
				
				this.$queryApi("get","/share/list?list_rows=10&page="+this.page, {
					// list_rows:10,
					// page:this.page
				}, res => {
					console.log(res,"分享列表")
					if(res.data.current_page >= res.data.last_page){
						this.isCanUp = false
					}else{
						this.isCanUp = true
					}
					let kongList = res.data.data;
					if(this.page == 1){
						this.yaoqingList =  kongList;
					}else{
						this.yaoqingList =  [...this.yaoqingList,...kongList];
					}
					setTimeout(()=>{
						uni.hideLoading()
					},500)
				},"","noMsg")
			},
			funxiang(){
				uni.showShareMenu({
					withShareTicket:true,
					success: function (res) {
					  console.log('分享菜单显示成功', res);
					},
					fail: function (res) {
					  console.log('分享菜单显示失败', res);
					}
				})
				uni.onShare
			},
			showTurnHandle(){
				uni.switchTab({
					url:"/pages/mine/mine"
				})
			},
		}
	}
</script>

<style lang="scss">
.header_title_c{
	color: #fff;
	font-size: 36rpx;
	font-weight: 400;
	left: 50%;
	position: absolute;
	top:50%;
	transform: translate(-50%,-50%);
}
.invite_view{
	position: relative;
	width: 690rpx;
	left: 30rpx;
	top: -260rpx;
	.invite_box{
		.tit_c{
			font-size: 28rpx;
			color: #1346B9;
			text-align: center;
			padding-bottom: 22rpx;
		}
		.img_box{
			width: 690rpx;
			height: 168rpx;
			position: relative;
			.yq2_img{
				width: 690rpx;
				height: 168rpx;
			}
			.yq2_box{
				position: absolute;
				width: 690rpx;
				height: 168rpx;
				box-sizing: border-box;
				padding: 30rpx 0 0 186rpx;
				top: 0;
				left: 0;
				color: #fff;
				.t1p{
					font-size: 36rpx;
				}
				.t2p{
					font-size: 30rpx;
					padding-top: 10rpx;
					.c_span{
						font-size: 36rpx;
					}
				}
			}
		}
		.list_box_b{
			background-color: #fff;
			border-radius: 40rpx;
			padding: 40rpx 20rpx;
			margin-top: 32rpx;
			.list_tit{
				font-size: 36rpx;
				font-weight: 500;
				padding-bottom: 6rpx;
			}
			.list_box{
				min-height: 26vh;
				.list_item{
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 10rpx 0;
					.left_b{
						display: inline-flex;
						align-items: center;
						.yqt_img{
							width: 72rpx;
							height: 72rpx;
							margin-right: 30rpx;
						}
						.t_name{
							font-size: 28rpx;
						}
					}
					.right_time{
						font-size: 28rpx;
					}
				}
			}
		}
	}
	.btn_yx_box{
		position: fixed;
		width: 690rpx;
		bottom: 0;
		left: 30rpx;
		padding: 10rpx 0 66rpx;
		background-color: rgba(246,246,246,.9);
		.btn_yx{
			width: 326rpx;
			padding: 0rpx 0 0rpx;
			background: linear-gradient( 90deg, #91B6FF 0%, #3677F6 99%);
			border-radius: 290rpx;
			border: 3rpx solid #ffffff;
			color: #fff;

			text-align: center;
			box-shadow: 0 4rpx 0 #3677F6;
			font-size: 36rpx;
			margin: 0 auto;
			line-height: 2.1;
		}
	}
}
</style>
